package com.xxxx.yoyo.adminweb;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xxxx.yoyo.service.IGoodsService;
import com.xxxx.yoyo.service.impl.GoodsServiceImpl;


@WebServlet("/admin/goodsDelete")
public class GoodsDeleteServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	private IGoodsService goodsSevice = new GoodsServiceImpl();
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//获取前端传递过来的参数id,status
		String goodsIdstr = request.getParameter ("id");
		int goodsId = Integer.parseInt(goodsIdstr);
		String statusStr = request.getParameter("status");
		int status = Integer.parseInt(statusStr);
		
		//根据宠物id删除宠物
		boolean isSuccess = goodsSevice.deleteGoodsById(goodsId);
		if(isSuccess){//删除成功
		//重定向返回到当初点击的那个页面(或请求转发也可以)
		response.sendRedirect("/YoyoShop/admin/goodsList?status="+ status +"&page=1&size=16");
		}
	}

}
